package com.ghostwan.androears.customObject;

import android.os.Parcel;
import android.os.Parcelable;

public class Song implements Parcelable{

	public String mSongName;
	public String mSongKey;
	public long mDuration;
	public String mSongCover;
	public String mPath;
	public String mArtistName;
	public String mArtistKey;
	public String mAlbumName;
	public String mAlbumKey;
	public int mIsPlayed;
	
	public Song(String name, String key) {
		super();
		mIsPlayed = 0;
		mSongName = new String("");
		key = new String("");
		mDuration = 0;
		mSongCover = new String("");
		mPath = new String("");
		mArtistName = new String("");
		mAlbumName = new String("");
		this.mSongName = name;
		this.mSongKey = key;
	}
	
	public Song(Parcel in) {
		readFromParcel(in);
	}
	
	private void readFromParcel(Parcel in) {
		mIsPlayed = in.readInt();
		mSongName = in.readString();
		mArtistName = in.readString();
		mAlbumName = in.readString();
		mSongKey = in .readString();
		mDuration = in.readLong();
		mSongCover = in.readString();
		mPath = in.readString();
		
	}
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		if(mSongName != null) dest.writeString(mSongName);
		if(mSongKey != null) dest.writeString(mSongKey);
		dest.writeLong(mDuration);
		dest.writeInt(mIsPlayed);
		if(mSongCover != null) dest.writeString(mSongCover);
		if(mPath != null) dest.writeString(mPath);
		if(mArtistName != null) dest.writeString(mArtistName);
		if(mAlbumName != null) dest.writeString(mAlbumName);
		
	}
	
	public static final Parcelable.Creator<Song> CREATOR = new Parcelable.Creator<Song>() {
        public Song createFromParcel(Parcel in) {
            return new Song(in);
        }

        public Song[] newArray(int size) {
            return new Song[size];
        }
    };
	
	
}
